﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.Model;
using System.Xml;

namespace iLangl.BusinessModel.Actions.Push
{
	public class SettingsForTPResponseContext : BaseResponseContext
	{
		private SettingsFromTP settings;
		public override void SetContext(object context)
		{
			base.SetContext(context);

			settings = new SettingsFromTP();

			XmlNode settingsnode = document.SelectSingleNode("//TPSettings");

			ParseExtendedInfo(settingsnode);

			LanguagesResponseContext langcontext = new LanguagesResponseContext();
			langcontext.SetContext(document);

			settings.Languages = (IList<Language>)langcontext.GetContext();

			ProductsResponseContext productContext = new ProductsResponseContext();
			productContext.SetContext(document);
			settings.Products = (IList<Product>)productContext.GetContext();

			WorkareaResponseContext termContext = new WorkareaResponseContext();
			termContext.SetContext(document);
			settings.WorkAreas = (IList<WorkArea>) termContext.GetContext();

			FireChanges();
		}

		public override object GetContext()
		{
			return settings;
		}
	}
}
